<?php

require_once('common/common.php');
require_once('common/Verifica_loggado.php');
$empresa = $user->getempresa();

$sql = 'SELECT
  FraID,
  FraStatus,
  FraFechaIngreso,
  FraReferenciaCo,
  FraBnfNombre,
  FraEnviado,
  miso_id,

  officeschema.hd_statusfacturas.sg_Descripcion AS estado
FROM officeschema.facturas
  INNER JOIN officeschema.facturasextjoins
    ON FraID = FraExtID
  LEFT OUTER JOIN officeschema.corresponsales
    ON CorrNumero = FraCashierCorr
  INNER JOIN officeschema.hd_modospago
    ON mp_ID = FraModoPago
  LEFT OUTER JOIN officeschema.hd_monedasiso
    ON miso_Cod_elite = FraMonDPago
  LEFT OUTER JOIN officeschema.hd_paises
    ON FraBnfPais = pai_CodElite
  LEFT OUTER JOIN systemoffice.main_users
    ON main_users.ref = FraOrigen2
  LEFT OUTER JOIN officeschema.origenes
    ON OriNumero = FraOrigen0
  LEFT OUTER JOIN officeschema.ciudades AS CliCiu
    ON CliCiu.CiuNumero = FraCliCiudad
  LEFT OUTER JOIN officeschema.ciudades AS BnfCiu
    ON BnfCiu.CiuNumero = FraBnfCiudad
    JOIN officeschema.hd_statusfacturas ON officeschema.hd_statusfacturas.sg_ID =officeschema.facturas.FraStatus

    WHERE officeschema.facturas.FraCorresponsal=300
    AND officeschema.facturas.FraModo=2
    AND officeschema.facturas.FraStatus NOT IN(11,9,10,21);';
$result = $db->getall($sql);

foreach ($result as &$value) {
	if ($value->FraStatus == 2) {
		$value->cor = 'black';
	} elseif ($value->FraStatus == 16) {
		$value->cor = 'green';
	} else {
		$value->cor = 'red';
	}
}
//printArray($result);
$smarty->assign('result', $result);
/* $smarty->assign('menu','pagamentos');
 $smarty->display('index.tpl'); */
$view->display();




